import random

def guess_num():
    random_num=random.randint(1,100)
    guess_count=7
    while guess_count>0:
        input_num=int(input("请输入："))
        if input_num>random_num:
            guess_count-=1
            print("猜大了")
            print(f"你还有{guess_count}次机会")
            continue
        elif input_num<random_num:
             guess_count-=1
             print("猜小了")
             print(f"你还有{guess_count}次机会")
             continue
        else:
            print("猜对了：")
            return
if __name__ == '__main__':
    guess_num()
